﻿@model MasResourceItem

@{
    int resSubGrpId = ViewBag.ResSubGrpId; 
    var resSubGrp = new KPIS.GERP.WEB.GIMS.MasResourceService.MasResourceServiceClient().SelectResourceSubGroup(new MasResourceSubGroup{RecordStatus = "!D", ResSubGrpId = resSubGrpId}, null).FirstOrDefault();
    var masUnit = new KPIS.GERP.WEB.GIMS.MasUnitService.MasUnitServiceClient().SelectMasUnit(new MasUnit{RecordStatus = "!D"}, null).FirstOrDefault(o => o.UnitId == Model.UnitId);  
}

@Html.Hidden("resSubGrpId", resSubGrpId)
@Html.HiddenFor(model => model.ResItemId)
@Html.HiddenFor(model => model.RecordStatus)

<div class="widget-box">
	<div class="widget-header header-color-blue2">
        <h4 class="lighter smaller">รายการพัสดุ</h4>
    </div>
    <div class="widget-body">
        <div class="widget-body-inner">
			<div class="widget-main form-horizontal">
                <div class="control-group">
                    <div class="control-label">
                        @Html.DisplayNameFor(model => model.Code)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.Code)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.OldCode)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.OldCode)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.Name)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.Name)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.Descr)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.Descr)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.ResSubGrpId)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @resSubGrp.Code - @resSubGrp.Name
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.GpscCode)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.GpscCode)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.GiinCode)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @Html.DisplayFor(model => model.GiinCode)
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.StdPrice)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(Model.StdPrice == null ? "" : Model.StdPrice.Value.ToString("#,##0.00 บาท"))
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.MinPrice)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(Model.MinPrice == null ? "" : Model.MinPrice.Value.ToString("#,##0.00 บาท"))
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.MaxPrice)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(Model.MaxPrice == null ? "" : Model.MaxPrice.Value.ToString("#,##0.00 บาท"))
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.UnitId)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(masUnit != null ? masUnit.Name + (string.IsNullOrWhiteSpace(masUnit.Code) ? "" :" [" +  masUnit.Code + "] ") : "")
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.MinQty)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(Model.MinQty == null ? "" : Model.MinQty.Value.ToString("#,##0.00"))
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                         @Html.DisplayNameFor(model => model.MaxQty)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @(Model.MaxQty == null ? "" : Model.MaxQty.Value.ToString("#,##0.00"))
                    </div>
                </div>
                <div class="control-group">
                    <div class="control-label">
                        @Html.DisplayNameFor(model => model.RecordStatus)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @{
                            string recordStatus = Model.RecordStatus;
                            if (recordStatus == "W")
                            {
                                recordStatus = "U";
                            }
                            string className = "";
                            switch (recordStatus)
                            {
                                case "U":
                                    className = "text-info";
                                    break;
                                case "A":
                                    className = "text-success";
                                    break;
                                case "W":
                                    className = "text-warning";
                                    break;
                                case "P":
                                    className = "muted";
                                    break;
                                case "J":
                                    className = "red";
                                    break;
                                default:
                                    break;
                            }
                        }
                        <span class="@className">
                            @RecordStatus.RecordStatusName(recordStatus)
                        </span>
                    </div>
                </div>    
                <div class="control-group">
                    <div class="control-label">
                        @Html.DisplayNameFor(model => model.ImageName)
                    </div>
                    <div class="controls-detail" style="margin-top:5px !important;">
                        @if (!string.IsNullOrWhiteSpace(Model.ImageName))
{
    string onclickScript = "javascript:popup(\"" + Url.Action("image", new { id = Model.ResItemId }) + "\"); ";
    <img class="imgBorder" src="@Url.Action("StreamFileFromDisk4", new {Model.ImageName})" style="cursor: pointer" onclick='@onclickScript' width="300px" />
}
else
{
                            <img class="imgBorder" src="~/Content/Images/Icon/no_image.png" />
                        }
                    </div>
                </div>             
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
<!--
function popup(url) 
{
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url,'windowname4', params);
 if (window.focus) {newwin.focus()}
 return false;
}
// -->
</script>